package com.itheima.day09_IO.Student;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        students.add(new Student("张三", "男", "20", "88"));
        students.add(new Student("李四", "女", "19", "99"));
        try(FileOutputStream fos = new FileOutputStream("D:\\img2\\student.txt")) {
            for (int i = 0; i < students.size(); i++) {
               fos.write(students.get(i).toString().getBytes());
               fos.write("\r\n".getBytes());

            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
